package com.stgy.lease.model.base;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.util.Date;

/**
 * ClassName:BaseDomain
 * Package:com.stgy.lease.dodel.base
 * Description:
 *
 * @Author:helei
 * @Create:2024/8/28 - 10:55
 */
@Data
@Schema(description = "实体类的基类")
public class BaseDomain {
    //雪花算法生成唯一id
    @TableId(type = IdType.ASSIGN_ID)
    //jackson将对象转为json字符串时，id属性转为字符串类型响应
    @JsonSerialize(using = ToStringSerializer.class) //解决精度丢失
    private Long id;

    @TableField(fill = FieldFill.INSERT)
    //时间日期格式化、时区配置
//    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonIgnore
    private Date createTime;

    @TableField(fill = FieldFill.INSERT_UPDATE)
    @JsonIgnore
//    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private Date updateTime;

    @TableField(value = "is_deleted")
    @TableLogic
    @JsonIgnore
    private Boolean deleted = false;
}
